package com.hxzy.remote;

import com.hxzy.common.vo.R;
import com.hxzy.product.entity.Sku;
import com.hxzy.remote.fallback.ProductServiceOpenFeignApiFallBackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/**
 *  产品远程访问的API
 *  fallbackFactory代表hystrix服务熔断或降级
 *
 * @author tonneyyy
 */
@FeignClient(name = "productserver",fallbackFactory = ProductServiceOpenFeignApiFallBackFactory.class)
public interface ProductServiceOpenFeignApi {

    /**
     * 根据spuid查询商品详情信息
     * @param spuId
     * @return
     */
    @GetMapping("/sku/spuid/{id}")
     R<List<Sku>> findSkusBySpuId(@PathVariable("id") String spuId);


    /**
     * 根据spuid查询数据
     * @param id
     * @return
     */
    @GetMapping(value = "/spu/es/{id}")
    R findSpuById(@PathVariable(value = "id") String id);


    /**
     * 根据分类的id查询名称
     * @param ids
     * @return
     */
    @GetMapping(value = "/category/names")
     R findNameByCategoryIds(@RequestParam(value = "ids") Integer[] ids);
}
